package manage

import (
	"github.com/gin-gonic/gin"
	"iot-base/auth/svc"
	"iot-base/auth/types"
)

func GetBrandList(c *gin.Context) {
	resp := types.NewResult(c)
	var data types.ResAirBrand
	err := c.ShouldBind(&data)
	if err != nil {
		resp.ErrorCode(types.ParamsError, err.Error())
		return
	}
	brands, err := svc.Dao.TBrand.GetBrandList()
	if err != nil {
		resp.ErrorCode(types.DBError, err.Error())
	}
	resp.Success(gin.H{"brands": brands})
}

func GetBrandParam(c *gin.Context) {
	resp := types.NewResult(c)
	var data types.ReqAirBrand
	err := c.ShouldBind(&data)
	if err != nil {
		resp.ErrorCode(types.ParamsError, err.Error())
		return
	}
	result, err := svc.Dao.TBrand.GetBrandParam(data.Brand, data.Specification)
	if err != nil {
		resp.ErrorCode(types.DBError, err.Error())
		return
	}
	resp.Success(result)
}
